package cn.tedu.design;
/*
Author     :Dsi
Date       : 2021/11/22 15:10
Description: 该类用于测试单例设计模式的实现方式二：懒汉式
*/

import java.io.BufferedOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;

public class Singleton02 {
    public static void main(String[] args) throws Exception {
        MySingle02 s = MySingle02.getMysingle02();
        MySingle02 s1 = MySingle02.getMysingle02();
        MySingle02 s2 = MySingle02.getMysingle02();
        System.out.println(s);
        System.out.println(s1);
        System.out.println(s2);

    }
}

class MySingle02 {
    private static MySingle02 m;
    private MySingle02() { }
    public static MySingle02 getMysingle02() {
        if (m == null) {m = new MySingle02();}
        return m;
    }
}